package com.happy3w.cmds.refactor.config;

import java.util.regex.Pattern;

public class CpiConfigBuilder {
    public static ChangePackageItemConfig build(ChangePackageItemConfigVo configVo) {
        if (configVo.getFromRegex() != null) {
            return RegexCpiConfig.builder()
                    .from(Pattern.compile(configVo.getFromRegex()))
                    .to(configVo.getTo())
                    .build();
        } else {
            return StartCpiConfig.builder()
                    .from(configVo.getFrom())
                    .to(configVo.getTo())
                    .build();
        }
    }
}
